package com.jy.adscm.operation.mscyb.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.operation.mscyb.bean.JqwbMachinemaintenanceinfo;
import com.jy.adscm.operation.mscyb.mapper.mysql.JqwbMachinemaintenanceinfoMapper;
import com.jy.adscm.operation.mscyb.service.JqwbMachinemaintenanceinfoService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2018-12-07
 */
@Service
public class JqwbMachinemaintenanceinfoServiceImpl extends ServiceImpl<JqwbMachinemaintenanceinfoMapper, JqwbMachinemaintenanceinfo> implements JqwbMachinemaintenanceinfoService {
    @Autowired
    JyUserMapper jyUserMapper;
    @Override
    public List<JqwbMachinemaintenanceinfo> selectByTid(String tid) {
        Wrapper<JqwbMachinemaintenanceinfo> wrapper=new EntityWrapper<>();
        wrapper.eq("TID",tid);
        List<JqwbMachinemaintenanceinfo> jqwbMachinemaintenanceinfos = super.selectList(wrapper);
        for (JqwbMachinemaintenanceinfo jqwbMachinemaintenanceinfo : jqwbMachinemaintenanceinfos) {
             if (AdscmBaseUtils.getInstance().isNotEmpty(jqwbMachinemaintenanceinfo.getPerson(),null)){
                 JyUser jyUser = jyUserMapper.selectById(jqwbMachinemaintenanceinfo.getPerson());
                 if (jyUser==null){
                     jqwbMachinemaintenanceinfo.setPersonName(jqwbMachinemaintenanceinfo.getPerson());
                 }else {
                     jqwbMachinemaintenanceinfo.setPersonName(jyUser.getName());
                 }


             }
        }
        return jqwbMachinemaintenanceinfos;
    }
}
